home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
ASSEMBLE
/
0419.ZIP
/
XASM.DOC
< prev
next >
Wrap
Text File
|
1986-03-05
|
10KB
|
303 lines
X A S M
Revision 1.04
A macro configured cross assembler
Copyright 1986 by Stuart Venters ALL RIGHTS RESERVED.
804 Watts Drive.
Huntsville, Alabama 35801
THIS SOFTWARE MAY NOT BE USED FOR PROFIT WITHOUT PRIOR WRITTEN
AUTHORIZATION FROM THE AUTHOR. The price is $50 and includes
the latest version release disk and your choice of target machine
definition file.
History and available targets
XASM is a cross assembler written for single chip computers. It was not
written for a specific target machine. It contains no built in machine
opcodes like JMP or LOAD. Instead these are provided by a macro definition
file for the particular target machine.
XASM is a personal tool which I think may be of general interest. I wrote
this assembler after working on several single chip projects with available
cross assemblers. This assembler eliminates problems I had with those
assemblers in areas of cost, speed, error checking, listing format, macro
implementation, and portability. It is 4 times faster than the last
assembler I bought or about 1500 LPM on a PC-AT. The listing is clean
showing all of the code bytes and none of the internal macro expansions.
XASM was written in C under CPM80. It currently runs on MS-DOS. The port
from CPM to MS-DOS took about two hours. This speaks well of both C and
the portability of XASM to other machines.
Plans are to enhance XASM in two directions: adding a relocating loader
and creating a microcode assembler for custom projects. I have made every
effort to ensure that XASM is a reliable tool. However, if you find a bug
or are interested in the enhancements please drop me a note.
XASM can be configured for a variety of targets. The current list of
macro files available for XASM is as follows:
1102MACS (Requires object code scrambler program.)
Seiko 1102 1112
SMC 1102
1650MACS General Instrument PIC-1650 series
6301MACS Hitachi 6301 6303 63701 6801 6803
Motorola 6800 6801 6803
6805MACS Hitachi 6305 6805
Motorola 6805 68705
8048MACS INTEL 8048 8041 series
Z8MACS ZILOG Z8 family
It is my intention to extend this list if there is demand. To this end
I will construct the required macro files for other targets as they are
ordered.
Operation
The assembler is invoked by a command line as follows:
XASM {debug} {filenames} mainfile
Files are read in order from left to right.
Filenames have ".ASM" appended to them.
Mainfile.ASM is the last source file.
Mainfile.LST is the list file.
Mainfile.HEX is the object file in INTEL hex format.
Example:
XASM 6805MACS UTIL TEST
Reads the macro definitions from 6805MACS.ASM
Reads the utilities file UTIL.ASM
Reads the test file TEST.ASM
Writes the object file TEST.HEX
Writes the listing file TEST.LST
Debug sets the internal debug level from 0 to 9.
-d1 is useful for watching assembler progress.
-d4 is useful for debugging macro definitions.
The source file is a text file of source lines. A source line consists of
a possible label field, an opcode field, and possibly some operand fields
separated by commas. The label field, if present, starts in column 1 and
may end with a colon. The opcode field is a single legal variable name
surrounded on both sides with spaces or tabs.
A real source file follows:
;define a macro SUM which puts out 1 byte which is the sum or it's arguments
sum macro
db $1+($2)
endm
a equ 16
b: set 7 ;
;now use the macro
LABEL: SUM a,b ;set LABEL equal to current pc,
; calls macro SUM with $1="A" and $2="B"
;
b set 8 ;
;
label sum A,b ;same, colon and case are not significant
sum a,b ;same, except no label (leading space is delimiter)
Assembler built in functions
SET sets the label to the left of the SET to the expression value
to the right. Can be done more than once in a pass. Value is not
recalculated in pass 2 but is saved from pass 1.
EQU sets the label to the left of the EQU to the expression value
to the right. Label can not have a previous value. Value is not
recalculated in pass 2 but is saved from pass 1.
ORG sets the program counter to the value of the expression to the
right of the ORG. Value is not recalculated in pass 2 but is saved
from pass 1.
DB outputs a byte or series of bytes according to the expression(s) to
the right of the DB. Legal byte values are from -128 to 255.
DW outputs a word or series of bytes according to the
expression(s) to the right of the DW.
PACKING sets the output mode for DW. PACKING 0 sets MSB first and is the
default. PACKING 1 sets LSB FIRST. PACKING 2 sets word mode.
ERROR marks the current line as being in error. The argument is a string
with the error code.
IFERR has two arguments. The second is evaluated and if non-zero
an error is caused using the first argument as the error value.
The evaluation occurs in both pass 1 and 2. If the expression is
undefined, no error occurs.
IF tests the expression to the right of the IF. If the expression is
non-zero, the if part is executed. If the expression is zero or
undefined, the else part is executed. The expression is not
recalculated in pass 2 but is saved from pass 1. Hence if's always
execute the same way in pass 1 and 2.
ELSE separates the true part from the false part of an IF sequence. Is
optional.
ENDIF terminates an IF sequence. Is not optional.
TITLE sets the current title string to the string to the right of TITLE.
PAGE causes printing to start on a new page
END causes assembly to stop. May be inside an IF statement.
MACRO causes all lines following until an ENDM to be stored as a macro
definition. The macro name is the label to the left of MACRO.
ENDM terminates a macro definition.
INCLUDE causes the file named in the quoted string to the right of INCLUDE
to be included in the source stream. Nesting is permitted.
Expressions
Expressions are evaluated from left to right with no hierarchy but
with parentheses. There are two types of operations. These are
numeric and string. All operations are dyadic. They take a left
and right value or expression in parens and put out an expression
value.
The numeric operations work on numeric values. If they
are given a string, they will use the character code of
the first string element as the numeric value. Arithmetic
is 16 bit unsigned. The list of operations is as follows:
+ addition
- subtraction
* multiply
/ divide
& bitwise and
| bitwise or
< relation less than. (0 if false, 1 if true)
> relation greater than. (0 if false, 1 if true)
= relation equal to. (0 if false, 1 if true)
! relation not equal to. (0 if false, 1 if true)
The string operations are included to make programming target
machine opcode macros easier. They operate on two strings.
The operations are as follows:
= Returns 1 if the strings are equal. 0 otherwise.
! Returns 0 if the strings are equal. 1 otherwise.
? Returns 1 if the characters in the first string
match the first characters in the second string.
Else returns 0.
^ Called with a string on the left and an expression
on the right. First removes the leading characters
in the expression which match the string. Next
evaluates the rest of the expression and returns
result.
Values
Values are the simplest form of an expression. There are three types
of values. These are constants, variables, and pseudo constants.
String constants are formed by a string of characters enclosed in
double quotes. A backslash is an escape character in a string. A
double quote can be entered by preceeding it with a backslash. Watch
backslashes in filenames of INCLUDE statements. (DOS takes forward
slashes just fine.)
Numeric constants always begin with "0" thru "9". Examples of
the possible numeric constants are as follows:
123 a simple base 10 number
123d the same base 10 number
10X123 the same base 10 number
16XABC the base 16 number ABC
ABCh the same base 16 number
0XABC the same base 16 number (base 0 --> base 16)
777q the base 8 number 777
8x777 same
101b the base 2 number 101
2x101 same
36x10Q the base 36 number 10Q
Variables always begin with "A" thru "Z". The following characters
may be "A"-"Z", "0"-"9", or "_". Examples of legal variables are:
A
A923
a923 (The same as case does not count.)
FIRST_ONE
FIRST_ONE_1 (Symbol size is not limited.)
Pseudo constants always begin with "$".
$ means the program counter value at the beginning of the
current source file line. (Not macro line.)
$1 means the first macro argument
.
.
$9 means the ninth macro argument
Values may be preceeded by a minus sign.